use core::{Dependency, Manifest, PackageId, Registry, Target, Summary, Metadata};
use core::dependency::SerializedDependency;
-use util::{CargoResult, graph};
+use util::{CargoResult, graph, Config};
use rustc_serialize::{Encoder,Encodable};
use core::source::Source;
+use sources::PathSource;
/// Informations about a package that is available somewhere in the file system.
///
}
}
+ pub fn for_path(manifest_path: &Path, config: &Config) -> CargoResult<Package> {
+ let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(),
+ config));
+ source.root_package()
+ }
+
pub fn dependencies(&self) -> &[Dependency] { self.manifest.dependencies() }
pub fn manifest(&self) -> &Manifest { &self.manifest }
pub fn manifest_path(&self) -> &Path { &self.manifest_path }
use std::io::prelude::*;
use std::path::Path;
-use core::{PackageSet, Profiles, Profile};
+use core::{Package, PackageSet, Profiles, Profile};
use core::source::{Source, SourceMap};
-use sources::PathSource;
use util::{CargoResult, human, ChainError, Config};
use ops::{self, Layout, Context, BuildConfig, Kind};
/// Cleans the project from build artifacts.
pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> {
- let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(),
- opts.config));
- let root = try!(src.root_package());
+ let root = try!(Package::for_path(manifest_path, opts.config));
let target_dir = opts.config.target_dir(&root);
// If we have a spec, then we need to delete some package,s otherwise, just
use std::path::Path;
use std::process::Command;
-use core::PackageIdSpec;
+use core::{Package, PackageIdSpec};
use ops;
-use sources::PathSource;
use util::{CargoResult, human};
pub struct DocOptions<'a> {
pub fn doc(manifest_path: &Path,
options: &DocOptions) -> CargoResult<()> {
- let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(),
- options.compile_opts.config));
- let package = try!(source.root_package());
+ let package = try!(Package::for_path(manifest_path, options.compile_opts.config));
let mut lib_names = HashSet::new();
let mut bin_names = HashSet::new();
use std::path::Path;
use ops;
-use core::{PackageIdSpec};
-use sources::{PathSource};
+use core::{PackageIdSpec, Package};
use util::{CargoResult, human, Config};
pub fn pkgid(manifest_path: &Path,
spec: Option<&str>,
config: &Config) -> CargoResult<PackageIdSpec> {
- let mut source = try!(PathSource::for_path(&manifest_path.parent().unwrap(),
- config));
- let package = try!(source.root_package());
+ let package = try!(Package::for_path(manifest_path, config));
let lockfile = package.root().join("Cargo.lock");
let source_id = package.package_id().source_id();
use ops::{self, ExecEngine, CompileFilter};
use util::{self, CargoResult, human, process, ProcessError};
-use sources::PathSource;
+use core::Package;
pub fn run(manifest_path: &Path,
options: &ops::CompileOptions,
args: &[String]) -> CargoResult<Option<ProcessError>> {
let config = options.config;
- let mut src = try!(PathSource::for_path(&manifest_path.parent().unwrap(),
- config));
- let root = try!(src.root_package());
+ let root = try!(Package::for_path(manifest_path, config));
let mut bins = root.manifest().targets().iter().filter(|a| {
!a.is_lib() && !a.is_custom_build() && match options.filter {
use core::dependency::Kind;
use core::manifest::ManifestMetadata;
use ops;
-use sources::{PathSource, RegistrySource};
+use sources::{RegistrySource};
use util::config;
use util::{CargoResult, human, ChainError, ToUrl};
use util::config::{Config, ConfigValue, Location};
token: Option<String>,
index: Option<String>,
verify: bool) -> CargoResult<()> {
- let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(),
- config));
- let pkg = try!(src.root_package());
+ let pkg = try!(Package::for_path(&manifest_path, config));
let (mut registry, reg_id) = try!(registry(config, token, index));
try!(verify_dependencies(&pkg, ®_id));
Some(ref name) => name.clone(),
None => {
let manifest_path = try!(find_root_manifest_for_cwd(None));
- let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(),
- config));
- let pkg = try!(src.root_package());
+ let pkg = try!(Package::for_path(&manifest_path, config));
pkg.name().to_string()
}
};
Some(name) => name,
None => {
let manifest_path = try!(find_root_manifest_for_cwd(None));
- let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(),
- config));
- let pkg = try!(src.root_package());
+ let pkg = try!(Package::for_path(&manifest_path, config));
pkg.name().to_string()
}
};